﻿#ifndef QQCELL_H
#define QQCELL_H

#include <QString>
#include <QList>
#include <QSharedPointer>
#include <QDebug>
#include <QMap>
#include <QDebug>

#include "unit.h"

typedef enum tagQQCellType_e
{
    QQCellType_Group = 0,               //好友组
    QQCellType_Child = 1,               //好友
    QQCellType_GroupEx = 2,             //群组
}QQCellType_e;

class QQCell;
class QQCellChild;
class QQCellGroup;
class ChatWin;

typedef QSharedPointer<QQCell> PtrQQCell;
typedef QSharedPointer<QQCellChild> PtrQQCellChild;
typedef QSharedPointer<QQCellGroup> PtrQQCellGroup;

class QQCell
{
public:
    QQCell(){}
    virtual ~QQCell(){}
public:
    QQCellType_e    type;
};

class QQCellGroup : public QQCell
{
public:
    QQCellGroup();
    ~QQCellGroup(){ qDebug() << "~QQCellGroup()"; }
    void SetSubTitle(const QString &text);
    void SetIconPath(const QString &path);
    void insertChildItem(const PtrQQCellChild& cell);
    bool removeChildItem(const PtrQQCellChild& cell);
    PtrQQCellChild removeChildItem(int QQid);
    void removeAllChild();
    int getOnlineCount();
    int getFriendCount(){ return m_mapChilds.size(); }
    PtrQQCellChild getPtrChildById(int QQid) { return m_mapChilds[QQid]; }
    QList<PtrQQCellChild> getlistChilds()
    {
        return m_mapChilds.values();
    }
public:

    //Group Information
    QString         m_strGroupName;     //组名
    QString         m_strIconPath;
    QString         m_strSubTitle;

    bool            m_bIsOpen;          //是否展开组员（子项）信息
private:
    //子项
    QMap<int,PtrQQCellChild> m_mapChilds;
    QList<PtrQQCellChild> m_listChilds;
};

class QQCellChild : public QQCell
{
public:
    QQCellChild() : m_strGroupName("我的好友"),m_pChatWin(NULL),m_UnReadMsg(0),m_bShake(false) {  type = QQCellType_Child; }
    ~QQCellChild(){ qDebug() << "~QQCellChild()"; }
    void SetSubTitle(const QString &text);
    void SetIconPath(const QString &path);
    void SetStatus(const quint8 &val);
public:
    User            m_childInfo;
    QString         m_strIpAddr;
    //Child Information
    QString         m_strGroupName;
    //QString         m_strIconPath;
    //QString         m_strName;          //子项昵称
    //QString         m_strSign;          //子项签名
    int             m_id;               //qq号，作为标识
    quint8          m_status;           //在线，离线
    ChatWin         *m_pChatWin;        //对应的聊天窗口
    int             m_UnReadMsg;        //未读消息条数
    bool            m_bShake;            //是否有窗口抖动的消息
};

#endif // QQCELL_H
